<?php $this->pageTitle = 'Payable Items Summary'; ?>
<?php Yii::app()->clientScript->registerScriptFile('/js/jquery.cookie/jquery.cookie.js'); ?>

<div class="flat_area">
    <div class="grid_16 content_header clearfix">
        <h1 class="float-left">Outstanding Payable Items For <?php echo $agentName; ?> </h1>
    </div>
    <div class="grid_16 relative">
		<div class="form box float-right">
			<div id="date-range" class="form">
				<?php $form = $this->beginWidget('PsActiveForm'); ?>
				<strong>Search payable items created between 
					<?php
					$form->widget('PsJuiDatePicker', array(
						'name' => 'from_date',
						'options' => array(
							'showButtonPanel' => false,
							'changeYear' => true,
							'dateFormat' => 'dd-mm-yy',
						),
					));
					?>
					and 
					<?php
					$form->widget('PsJuiDatePicker', array(
						'name' => 'to_date',
						'options' => array(
							'showButtonPanel' => false,
							'changeYear' => true,
							'dateFormat' => 'dd-mm-yy',
						),
					));
					?>
				</strong>
				<?php echo CHtml::submitButton('Search', array('name' => 'range-submit')); ?>
				<?php $this->endWidget(); ?>
			</div>
		</div>
		<br/>
		<br/>
		<?php $form = $this->beginWidget('PsActiveForm'); ?>
		<div id="ps-payable-items-details-index" class="box">
			<h2 class="box_head grad_colour with-icon"><img width="16" height="16" src="/images/icons/fugue/folder.png" /><?= ucwords($viewName); ?> Payment Details </h2>
			<?php
			$this->widget('PsGridView', array(
				'id' => 'payable-items-grid',
				'dataProvider' => $dataProvider,
				'template' => '{items}{pager}{pagesize}',
				'emptyText' => $emptyText,
				'htmlOptions' => array(
					'class' => 'grid-view grey'
				),
				'pagerCssClass' => 'pager float-right',
				'pagesizeCssClass' => 'pager-pagesize float-right',
				'columns' => array(
					array(
						'header' => 'Record created on',
						'name' => 'create_time',
						'type' => 'raw',
						'value' => '(date("d-m-Y", strtotime($data->create_time)))',
						'htmlOptions' => array(
							'width' => 100
						)
					),
					array(
						'header' => 'For payments received on',
						'name' => 'payment_date',
						'type' => 'raw',
						'value' => 'Yii::app()->dateFormatter->formatDateTime(strtotime($data->payment->payment_date), "short", null)',
						'htmlOptions' => array(
							'width' => 130
						)
					),
					array(
						'header' => 'Commission Type',
						'name' => 'comm_type',
						'type' => 'raw',
						'value' => '(ucfirst($data->comm_type))',
						'htmlOptions' => array(
							'width' => 100
						)
					),
					array(
						'header' => 'Amount Payable',
						'name' => 'amount',
						'type' => 'raw',
						'value' => 'Yii::app()->numberFormatter->formatCurrency($data->amount, "$ ")',
						'htmlOptions' => array(
							'width' => 100
						)
					),
					array(
						'header' => 'For the Property Transacted At',
						'name' => 'prop_address_formatted',
						'type' => 'raw',
						'value' => '$data->propertyCase->property->prop_street',
						'htmlOptions' => array(
							'width' => 300
						)
					),
					array(
						'header' => 'Include in new payment voucher',
						'name' => 'prop_address_formatted',
						'type' => 'raw',
						'value' => 'CHtml::checkBox("chkPaymentDetail[$data->id]", true, array("value" => $data->amount))',
						'htmlOptions' => array(
							'width' => 150
						)
					),
				),
			));
			?>

		</div>

		<!--        <div>
		<?php if (!$showDeleted): ?>
																									<a class="float-left blue link" href="<?php echo $this->createUrl('paymentVoucher/index', array('showDeleted' => true, 'view' => $view)); ?>">Show Cancelled</a>
		<?php else: ?>
																									<a class="float-left blue link" href="<?php echo $this->createUrl('paymentVoucher/index', array('view' => $view)); ?>">Hide Cancelled</a>
		<?php endif; ?>
				</div>-->
		<div class="content_header_controls">
			<a id="back" class="link-button with-icon" href="<?php echo $this->createUrl('paymentVoucher/outstandingSummary'); ?>">
				<img src="/images/icons/fugue/ui-button-navigation-back.png" />
				Back to Summary
			</a>
			<?php echo CHtml::submitButton('Enter Payment Voucher Details', array('name' => 'items-submit', 'class' => 'green')); ?>
			<?php $this->endWidget(); ?>
		</div>
	</div>
</div>
<script type="text/javascript">
	var welcomePopupEnabled = <?php echo ($welcomePopupEnabled ? "true" : "false"); ?>;
	var showWhatsNew = <?php echo ($showWhatsNew ? "true" : "false"); ?>;
</script>